package com.kkb.service.impl;

import com.github.pagehelper.PageInfo;
import com.kkb.mapper.TbOrderItemMapper;
import com.kkb.mapper.TbSubOrderMapper;
import com.kkb.page.TableDataInfo;
import com.kkb.pojo.*;
import com.kkb.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *订单列表实现类
 **/
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private TbSubOrderMapper orderMapper;

    @Autowired
    private TbOrderItemMapper orderItemMapper;
    /**
     * 获取订单列表
     * @param order
     * @return
     */
    @Override
    public List<TbSubOrder> selectOrderList(TbSubOrder order) {
        TbSubOrderExample example = new TbSubOrderExample();
        List<TbSubOrder> orderLists = orderMapper.selectByExample(example);
        return orderLists;
    }

    /**
     * 根据ID获取订单明细
     * @param ordersubId
     * @return
     */
    @Override
    public TbOrderItem selectOrderById(String ordersubId) {
        TbOrderItemExample example = new TbOrderItemExample();
        TbOrderItemExample.Criteria criteria = example.createCriteria();
        criteria.andOrdersubIdEqualTo(ordersubId);
        return orderItemMapper.selectByExample(example).get(0);
    }
}
